

import http from "@/utils/http"

//定义类型
interface RegionType{
    id:number|string,
    name:string
}
interface ProvinceType extends RegionType{}
interface CityType extends RegionType{
    provinceId:number|string
}
interface DistrictType extends RegionType{
    cityId:number|string
}

//定三个接口
let getProvinceList = ()=>{
    return http.get<ProvinceType[]>('/admin/region/province/list');
}

let getCityList =(provinceId:number|string)=>{
    return http.get<CityType[]>(`/admin/region/city/listByProvinceId?id=${provinceId}`);
}

let getDistrictList=(cityId:number|string)=>{
    return http.get<DistrictType[]>(`/admin/region/district/listByCityId?id=${cityId}`);
}

//对外导出
export {
    type ProvinceType,
    type CityType,
    type DistrictType,
    getProvinceList,
    getCityList,
    getDistrictList
}